package folexpr.compiler.visitors.g_skolem;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class SkolemVisitParameter
{
	// associa ad ogni variabile la lista delle variabili quantificate univ. che la precedono.
	// ogni variabile di questa mappa deve essere sostituita con una funzione
	// delle variabili che compaiono nella lista associata.
	private Map<String,Collection<String>> skolemSubstitutionMap;

	//variabili quantificate universalmente che mi precedono
	private Collection<String> belongingToVarList;

	//lista dei funtori utilizzati fin'ora nelle sostituzioni di skolem
	private Collection<String> userSubstitutionFunctors;
	
	private boolean skolemSubstitutionFlag = true;

	public SkolemVisitParameter(int functorIndex,int constantIndex)
	{	
		this.skolemSubstitutionMap = new HashMap<String,Collection<String>>();
		this.belongingToVarList = new ArrayList<String>();
		this.userSubstitutionFunctors = new ArrayList<String>();
	}

	//////////////////////////////////////////////////////////////////
	
	public Collection<String> getBelongingToVarList() {
		return belongingToVarList;
	}
	public void setBelongingToVarList(Collection<String> belongingToVarList) {
		this.belongingToVarList = belongingToVarList;
	}

	public Map<String, Collection<String>> getSkolemSubstitutionMap() {
		return skolemSubstitutionMap;
	}
	public void setSkolemSubstitutionMap(
			Map<String, Collection<String>> skolemSubstitutionMap) {
		this.skolemSubstitutionMap = skolemSubstitutionMap;
	}
	
	public Collection<String> getUserSubstitutionFunctors() {
		return userSubstitutionFunctors;
	}
	public void setUserSubstitutionFunctors(
			Collection<String> userSubstitutionFunctors) {
		this.userSubstitutionFunctors = userSubstitutionFunctors;
	}
	
	//////////////////////////////////////////////////////////////////
	
	public void addBelongingToVar(String var){
		this.belongingToVarList.add(var);
	}
	
	public void addSkolemSubstitutionVar(String var,String skolemVar)
	{
		if (this.skolemSubstitutionMap.containsKey(var))
		{
			//TODO control this overwrite/update!!!!! 
			Collection<String> vars = this.skolemSubstitutionMap.get(var);
			vars.add(skolemVar);
			this.skolemSubstitutionMap.put(var,vars);	
		}
		else
		{
			Collection<String> varList = new ArrayList<String>();
			if (skolemVar!=null) varList.add(skolemVar);
			this.skolemSubstitutionMap.put(var,varList);	
		}
	}

	///////////////////////////////////////////////////////////////////

	public boolean getSkolemSubstitutionFlag() {
		return skolemSubstitutionFlag;
	}
	public void setSkolemSubstitutionFlag(boolean skolemSubstitutionFlag) {
		this.skolemSubstitutionFlag = skolemSubstitutionFlag;
	}
	
}
